<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        /* 1、构建要素  =geometry+style+attr */
        /* .在编程语言中就读 的 */
        const point = new ol.Feature({
            geometry: new ol.geom.Point([114.30, 30.50]),
            id: 10001
        })
        // point.setId(1000)
        console.log(point)
        console.log(point.get("id"))
        let style = new ol.style.Style({
            //形状
            image: new ol.style.Circle({
                /* radius 设置半径 */
                radius: 30,
                fill: new ol.style.Fill({
                    color: '#ffcc33'
                }),
                // 边框（描边）
                stroke: new ol.style.Stroke({
                    color: "#333",
                    width: 5
                })
            })
        })
        // point.setStyle(style)

        /* 2、将要素添加到source */
        let source = new ol.source.Vector({
            // features: [point]
        })
        // source.addFeature(point)
        source.addFeatures([point])
        // console.log(source)  addFeature  addFeatures
        /* 3、将source设置layer */
        let layer = new ol.layer.Vector({
            // source,
            // style
        })
        layer.setSource(source)
        layer.setStyle(style)
        console.log(layer)
        /* 4、将layer添加map */
        map.addLayer(layer)
    </script>
</body>

</html>